package com.jiaai.web.zfp;

import com.alibaba.dubbo.config.annotation.Reference;
import com.jiaai.live.api.ILiveApi;
import com.jiaai.live.model.VLiveInfo;
import com.jiaai.member.api.IMemberApi;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Map;

/**
 * class_name:PageController
 * describe:------------------>返回页面
 * create_user:张昉平
 * create_date:2018/1/29
 * create_time:15:20
 */
@Controller
@RequestMapping("/api/v1/app/page")
public class PageController {

    @Reference
    private IMemberApi memberApi;
    @Reference
    private ILiveApi liveApi;

    /**
     * 我的等级
     */
    @GetMapping("/member/{mId}")
    public String member(@PathVariable String mId, ModelMap modelMap){
      //  HashMap map = memberApi.getLevelPage(mId);
       // modelMap.addAllAttributes(map);
        return "Member";
    }

    /**
     * 分享直播
     */
    @GetMapping("/shareLive/{liveId}")
    public String shareLive(@PathVariable Integer liveId, ModelMap modelMap){
        Map<String,Object> info = null;
        try {
            info = liveApi.getLiveInfo(liveId,"");
        } catch (Exception e) {
            e.printStackTrace();
            return "/error";
        }

//        if (info.getStatus() == 1){//正在直播
//            modelMap.addAttribute("url", info.getPullUrl());
//            return "play";
//        }else {//直播结束
//            modelMap.addAttribute("list", info.getRecommends());
//            modelMap.addAttribute("avatar", info.getAvatar());
//            modelMap.addAttribute("nickName", info.getNickName());
//            modelMap.addAttribute("mId", info.getmId());
//            return "wait_moment";
//        }
        return "play";
    }

}
